package com.sinaapp.gavinzhang.GSpider.common;

import com.caucho.hessian.client.HessianProxyFactory;
import com.sinaapp.gavinzhang.GSpider.management.HeartBeat;
import com.sinaapp.gavinzhang.GSpider.management.Register;

import java.net.MalformedURLException;
import java.util.ArrayList;
import java.util.Objects;

/**
 * @author gavin
 * @version 1.0
 * @date 2016/4/5
 * @description 获取代理对象
 */
public class RegisterUtil {
    public static HessianProxyFactory factory;
    static {
        factory = new HessianProxyFactory();
        //factory.setConnectTimeout(1000);
    }

    public static Object getHessianServer(Class<?> c, String urlName)throws MalformedURLException{
        return factory.create(c,urlName);
    }

    public static Object getHessianServer(Class<?> c,String ip,int port,String address)throws MalformedURLException{
        String urlname = "http://" + ip + ":" + port + "/" + address;
        return getHessianServer(c,urlname);
    }

    public static Register getRegister(String ip, int port, String address) throws MalformedURLException {
        return (Register) getHessianServer(Register.class, ip,port,address);
    }
}
